print("");

# 1.字典定义
## 字面量
{"name":"小白", "age":18}

## 空字典
empty_map_1 = {};
empty_map_2 = dict();

## 字典定义
map_1 = {"name":"小白", "age":18}

## 字典嵌套
map_2 = {
    "name":"小白",
    "age":18,
    "info": {
        "phone": 18866669999
    }
}

# 2.map操作
## 取出字典内容
map_demo = {
    "name": "小白",
    "age": 18
}
print("map_demo[name] = %s" %(map_demo["name"]));

## 新增字典元素
map_demo["addr"] = "中国";
print("新增后的字典%s" %(map_demo))

## 更新字典元素
map_demo["age"] = 20;
print("更新内容后的字典%s" %(map_demo))

## 删除字典元素
map_demo.pop("addr");
print("删除后的字典%s" %(map_demo))

## 清空字典
map_demo.clear();
print("清空后的字典%s" %(map_demo))

## 获取字典全部key
map_demo = {
    "name": "小白",
    "age": 18
}
print("字典全部key:%s" %(map_demo.keys()))

## 获取字典元素个数
print("字典元素个数:%s" %(len(map_demo)))

# 3.map遍历
print("----- map遍历 -----");
for key in map_demo.keys():
    print("%s --> %s" %(key, map_demo[key]));
print("")